use "GBK_CCES_data.dta", clear

* Table 1 *
sum white female college homeowner christian catholic gop3 dem3 
sum age, detail
tab ideo5

* Create distance from plant measures in 100kms for table *
gen eplantdist2 = eplantdist/100
gen eplantdistxcontrol2 = eplantdistxcontrol/100
gen eplantdistxhealth2 = eplantdistxhealth/100
label var eplantdist2 "Distance from plant (in 100s km)"
label var eplantdistxcontrol2 "Distance from plant (in 100s km) * Control"
label var eplantdistxhealth2 "Distance from plant (in 100s km) * Health treatment"

* Table 2 *
logit extend bottomhalf healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female homeowner  religiosity christian catholic 
outreg2 using table2, word label dec(3) sortvar(bottomhalf under25mi eplantdist healthprime gop3 dem3 globalwarmingbin1 education age white female homeowner  religiosity christian catholic) replace
logit extend under25mi  healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female homeowner  religiosity christian catholic 
outreg2 using table2, word label dec(3) sortvar(bottomhalf under25mi eplantdist healthprime gop3 dem3 globalwarmingbin1 education age white female homeowner  religiosity christian catholic) append  
logit extend eplantdist2 healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female  homeowner  religiosity christian catholic if eplantdist <=200
outreg2 using table2, word label dec(3) sortvar(bottomhalf under25mi eplantdist2 healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female homeowner  religiosity christian catholic) append  

* Table 3 *
logit extend bottomhalfxcontrol bottomhalfxhealth healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female homeowner  religiosity christian catholic
outreg2 using table3, word label dec(3) replace
test bottomhalfxcontrol= bottomhalfxhealth
logit extend under25mixcontrol under25mixhealth  healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female homeowner  religiosity christian catholic
outreg2 using table3, word label dec(3) append 
test under25mixcontrol=under25mixhealth 
logit extend eplantdistxcontrol2 eplantdistxhealth2 healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female  homeowner  religiosity christian catholic if eplantdist <=200
outreg2 using table3, word label dec(3) sortvar(bottomhalfxcontrol bottomhalfxhealth under25mixcontrol under25mixhealth eplantdistxcontrol2 eplantdistxhealth2   healthprime gop3 dem3 conservative2 globalwarmingbin1 education age white female homeowner  religiosity christian catholic) append 
